package com.example.springboot.controller;

import com.example.springboot.entity.BlogCorrect;
import com.example.springboot.entity.vo.BlogCorrectVO;
import com.example.springboot.service.BlogCorrectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/blog_corrects")
public class BlogCorrectController {
    @Autowired
    BlogCorrectService blogCorrectService;
    @PostMapping
    public ResponseEntity<BlogCorrect> create(@RequestBody BlogCorrect blogCorrect) {
        System.out.println(blogCorrect);
        blogCorrectService.insert(blogCorrect);
        return new ResponseEntity<>(null, HttpStatus.OK);
    }
    @GetMapping
    public ResponseEntity<List<BlogCorrectVO>> find(@RequestParam(defaultValue = "1") Integer pageNum, @RequestParam(defaultValue = "10") Integer pageSize,
                                            @RequestParam Integer postId,@RequestParam String textId) {
        List<BlogCorrectVO> blogCorrectList = blogCorrectService.findList(pageNum, pageSize, postId, textId);
        return new ResponseEntity<>(blogCorrectList, HttpStatus.OK);
    }
}
